<template>
  <div class="app-container">

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:userActiveMessaging:remove']"
        >删除</el-button>
      </el-col>
    </el-row>

    <!-- :default-expand-all='true' -->

    <el-table v-loading="loading" :data="userActiveMessagingList" @selection-change="handleSelectionChange" >
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" class="demo-table-expand">
            <el-form-item label="文本内容">
              <span>{{ props.row.content }}</span>
            </el-form-item>
            <el-form-item label="文件内容">
              <span>{{ props.row.photoMessagePath }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>

      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="id" align="center" prop="id" /> -->
      <el-table-column label="发布时间" align="center" prop="sendTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sendTime)}}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核通过时" align="center" prop="applyTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="评论数" align="center" prop="commentCount" />
      <el-table-column label="喜欢数" align="center" prop="likeCount" />
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listUserActiveMessaging, delUserActiveMessaging } from "@/api/system/userActiveMessaging";

export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 用户动态消息表格数据
      userActiveMessagingList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type: 1,
        accountId: undefined,
        status: undefined
      },
    };
  },
  created() {
    
  },
  methods: {
    init(id){
      this.queryParams.accountId = id
      this.getList();
    },
    /** 查询用户动态消息列表 */
    getList() {
      this.loading = true;
      listUserActiveMessaging(this.queryParams).then(response => {
        this.userActiveMessagingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除用户动态消息编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delUserActiveMessaging(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    }
  }
};
</script>